<?php

/**

 * 登录
 * 
 * @access  public 
 * @author  zhangyingheng<zhang_yh@jsumt.com.cn> 
 */

namespace Index\Controller;

use Think\Controller;
use Org\Util\Rbac;
use Think\Verify;

class LoginController extends Controller {
    
    public function valid() {
        vendor('weixin');
        $wechatObj = new \Weixin();
        $wechatObj->valid();
    }

    public function index() {
        if (IS_AJAX) {
            $map['USER_ID'] = trim(I('user_id'));
            $row = M('user')->where($map)->find();
            if ($row) {
                session('user_id', $row['user_id']);
                session('user_name', $row['user_name']);
                session('dept_id', $row['dept_id']);
                session('dept_id_other', $row['dept_id_other']);
                session('user_priv', $row['user_priv']);
                session('user_priv_other', $row['user_priv_other']);
                $return['info'] = false;
                $return['url'] = U('Index/index');
                
                
            }
            $this->ajaxReturn($return);
        }
//        $user = M('user')->where('USER_ID','huangweijiang')->find();
//        print_r($user);
        $this->display();
    }

    //退出
    public function logout() {
//        $content = session('oa_user_name') . '于' . date('Y-m-d H:i:s') . '退出了' . session('oa_company_name');
//        $operationData = array('type' => 1, 'content' => $content, 'user_id' => session('oa_user_id'), 'role_id' => session('oa_role_id'), 'company_id' => session('oa_company_id'));
//        setOperation($operationData);

        session(null);
        redirect(U('Index/Login/index'));
    }

}
